POV-Ray : Newsgroups : povray.general : image based normal maps? : Re: image based normal maps? Server Time
27 Apr 2024 08:45:24 EDT (-0400)
  Re: image based normal maps?  
From: Thomas de Groot
Date: 20 Jan 2019 02:58:30
Message: <5c442a26$1@news.povray.org>
On 19-1-2019 20:40, Bald Eagle wrote:
> "Kenneth" <kdw### [at] gmailcom> wrote:
> 
>> Since the use of the function requires a color component to be chosen, I used
>>        .blue
>> because the blue color in this particular image_map is the dominant one, with
>> the most gradations. Using .red, .green, or .gray  shows practically no effect.
>>
>> I don't presently know how to use the *complete* range of colors in the image,
>> as a way to pick out the normal patterns in the normal_map-- like, red for
>> bumps, green for granite, and blue for a third normal pattern. It would *seem*
>> to be possible, though, with some SDL/function tricks(?)
> 
> 
> I started coding a function this morning, and just got back to it now.
> Glad to see ole' Kenneth Walker is keeping his Northern namesake on his toes
> with the speedy competition.   ;)
> 
> Try some of this out, and see what you think:
> 
> 
> #declare Type = 1;
> #switch (Type)
> 
> #case (0)
> box {<0, 0, 0>, <1, 1, 0.1>
>    texture {pigment {Blue*0.5} finish {specular 0.4}}
>    normal {bump_map {png "PovLogo.png" once} bump_size 2}
> 
>   }
> #break
> 
> #case (1)
> 
> #declare BumpMap = function {pigment {image_map {png "PovLogo.png"} }};
> 
> 
> box {<0, 0, 0>, <1, 1, 0.1>
>    texture {pigment {Blue*0.5} finish {specular 0.4}}
>       //normal {function { BumpMap (x, y, z).gray}}
>       normal {
>        function {
>        BumpMap (x, y, z).red +
>        BumpMap (x, y, z).green +
>        BumpMap (x, y, z).blue}
>       }
> }
> 
> #break
> #end
> 
> 

Sorry, I am afraid I made myself not too clear or, more probably, I 
mis-read Bald Eagle's initial answer (the last paragraph). I certainly 
got a fine working normal, but got lost with that 'function pattern' 
hint at the end and went looking for function_patterns... :-)

What I did, and what worked fine was this:

#local NormalMap =
function {
   pigment {
     image_map {
       jpeg "MyImage.jpg" gamma 1
     }
   }
}

sphere {
   0, 1
   pigment {rgb 1}
   normal {
     function {NormalMap(x,y,z).grey} 1.5
     scale 0.5
   }
   finish {
     diffuse 1
   }
}

Note that I replaced the '.red' by '.grey' which gives a better render. 
What also works fine here is '.hf' by the way. And so it seems, we were 
all (Kenneth, Bald Eagle, Clipka, me) on the same wavelength.

However, Bald Eagle's

     function {
       NormalMap(x,y,z).red +
       NormalMap(x,y,z).green +
       NormalMap(x,y,z).blue
     } 1.5

gives a much better result and thus may be preferred.

Kenneth's suggestion to use the three colours for three different 
normals may be worth investigating further...

Now, that was a nice little experimental session. Keeps me on my toes. 
Thanks all!

-- 
Thomas


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.